#if !defined(MOUSECTRACERMANGERIMPL2_H_INCLUDED)
#define MOUSECTRACERMANGERIMPL2_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma warning(push)
#pragma warning(disable: 4786)	// identifier was truncated to "number'
								// characters in the debug information

#include "MouseTracerManager.h"

// forward reference;
template<class T>
class CMouseTracer;

/**
 *	CMouseTracerManagerImpl2 class
 *
 *	Type 2 : setup application hook to monitor mouse activities on active window
 *				a temporary window is created/used to receive the captured mouse message
 *				m_mouseTracer(CMouseTracer) is only included to take advantage of its behavioral property
 *
 */
class CMouseTracerManagerImpl2
{
	friend class CMouseTracerManager<CMouseTracerManagerImpl2>;

public:
	static BOOL SetupMouseTracer(HINSTANCE hMod = NULL) { return CMouseTracerManagerImpl2::Instance().Setup(hMod); }
	static void RemoveMouseTracer() { CMouseTracerManagerImpl2::Instance().Remove(); }

	protected:
	static CMouseTracerManagerImpl2 &Instance() { static CMouseTracerManagerImpl2 instance; return instance; }

public:
	CMouseTracerManagerImpl2();
	virtual ~CMouseTracerManagerImpl2();

private:
	BOOL Setup(HINSTANCE hMod = NULL);
	void Remove();

private:
	static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
	
    static HHOOK m_hHook;
	static CMouseTracer<CMouseTracerManager<CMouseTracerManagerImpl2> > m_mouseTracer;

	static HWND m_hWnd;
	static BOOL m_bValidTarget;
};

#pragma warning(pop)

#endif // !defined(MOUSETRACERMANGERIMPL2_H_INCLUDED)
